import pymysql

if __name__ == '__main__':
    #连接对象
    conn = pymysql.connections.Connection(host="127.0.0.1",port=3306,user="root",passwd="root",db="shop")
    #定义sql
    sql = "insert into user(username,password) values(%s,%s)"
    #获取游标对象
    cusor = conn.cursor()
    
    #执行sql
    result = cusor.execute(sql,["admin","admin"])
    #提交事务
    conn.commit()

    cusor.close()
    conn.close()
